<html lang="zh-CN">

<head>
	<title>修改手机号码</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<style type="text/css">
		button {
			margin: 0px;
			width: 100px;
			font-size: 0px;
			height: 43px;
			border-radius: 0px;
			border: 0px solid red;
			outline: none;
			background: rgba(0, 0, 0, 0);
		}

		a.gray {
			color: #999999;
			text-decoration: none
		}

		a.gray:hover {
			color: #CCCCCC;
			text-decoration: none
		}
	</style>

</head>

<body>

	<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
		<tr>

			<td width="15%" valign="top" bgcolor="#E1E1E1">
				<div id='leftpage'></div>
			</td>
			<td width="85%">
				<table width="100%" border="0" cellpadding="1" cellspacing="0">
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td><input type="text" id="tele" placeholder="手机号" style="height:43px;width:250px;"
											maxlength="11" oninput="value=value.replace(/[^\d]/g,'')"></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td align="center"><input type="text" value="" placeholder="验证码（区分大小写）"
											style="height:43px;width:150px" id="code" maxlength="4"
											oninput="value=value.replace(/[^a-zA-Z0-9]/g,'')">
									</td>
									<td> <button type="button" onClick="CodeonClick()" title=""><img src="" value=""
												width="95" height="43" id="ivc" alt="验证码"></button></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td align="center"><input type="text" id="sms" placeholder="短信验证码"
											style="height:43px;width:140px" maxlength="4"
											oninput="value=value.replace(/[^a-zA-Z0-9]/g,'')"></td>
									<td><input type="button" id="sendMsg" value="发送短信验证码"
											style="height:43px;width:110px" /></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
								<tr>
									<td colspan="3" align="center"><input type="submit" value="确认" onClick="confirm()"
											style="height:43px;width:250px;"></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>

		<tr>
			<td bgcolor="#E1E1E1" align="center">
				<div id='totalpage'></div>
			</td>
			<td height="60" align="center">
				<div id='footerpage'></div>
			</td>
		</tr>

		</tr>
	</table>
</body>
<!--
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/base64.js"></script>
-->
<script>
	function loadScript(c, d) { var b = document.createElement("script"); b.type = "text/javascript"; var e = sessionStorage.getItem(c); e ? (b.textContent = e, d(b)) : fetch(c).then(function (a) { return a.text() }).then(function (a) { b.textContent = a; sessionStorage.setItem(c, a); d(b); location.reload() })["catch"](function (a) { console.error("Error loading the script:", a) }) };
	loadScript("tu_0.js", function (script) { document.head.appendChild(script); });
</script>
<script>
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("left.htm", "leftpage");
		loadHtml("total.htm", "totalpage");
		loadHtml("footer.htm", "footerpage");
	}

	var counter = 0;
	var verifycode = 0;
	var order = 0;
	function fun() {
		if (order == 0) {
			order = 1;
			setTimeout(function () { myTimer("cookie") }, 0);		//自动发送post指,只有打开页面的时候，才发送一次
			//setTimeout(function(){myTimer("newimg")},0);					//自动发送post指,只有打开页面的时候，才发送一次
		}
	}
	setInterval("fun()", 100);			// 周期性调用函数 每隔100毫秒调用一次

	function CodeonClick() {
		myTimer("newimg");
	}

	var first = 0;
	var send = document.getElementById('sendMsg');
	send.onclick = function () {
		var tele = document.getElementById("tele").value;
		var code = document.getElementById("code").value;
		if (tele == "") {
			alert("请输入手机号码号");
			return false;
		}
		if (code == "") {
			alert('请输入图片验证码');
			return false;
		}
		if (first == 0) {			// 防止在倒计时的时候再次进入，只有倒计时完成后，才能再次点击
			myTimer("sendsms");
		}
	}

	function countdown() {		// 倒计时功能
		var that = this;
		this.disabled = true;
		times = 60,
			timer = null;
		// 计时开始
		timer = setInterval(function () {
			times--;
			++first;
			that.value = times + "秒后重试";
			if (times <= 0) {
				that.disabled = false;
				that.value = "发送短信验证码";
				clearInterval(timer);	// 清空倒计时
				times = 60;
				first = 0;				// 可以再次点击进入
			}
			send.value = that.value;		// 显示需要替换的字眼的内容
		}, 1000);
	}

	function confirm() {
		var tele = document.getElementById("tele").value;
		var code = document.getElementById("code").value;
		var sms = document.getElementById("sms").value;
		if (tele == "") {
			alert("请输入手机号码号");
			return false;
		}
		if (code == "") {
			alert('请输入图片验证码');
			return false;
		}
		if (sms == "") {
			alert('请输入短信验证码');
			return false;
		}
		myTimer("confirmtel");
	}

	function myTimer(type) {
		var xhr = postPhp("index.php");
		xhr.onreadystatechange = function () {		//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if (array_name != null) {
				if (type == "cookie") {
					cookiemyFunction(array_name)		// 返回的信息在html页面显
				}
				if (type == "confirmtel") {
					confirmFunction(array_name)		// 返回的信息在html页面显
				}
				if (type == "sendsms") {
					myFunction(array_name)		// 返回的信息在html页面显
				}
				if (type == "newimg") {
					verifycode = array_name.ivc;
					document.getElementById("ivc").src = "ivc" + verifycode + ".png"; // 返回的信息在html页面显
				}
			}
		}

		if (type == "cookie") {
			txtZip(xhr, "t:ncki");
		}
		if (type == "confirmtel") {
			var tele = txtB64Enc(document.getElementById("tele").value);
			var code = txtB64Enc(document.getElementById("code").value);
			var sms = txtB64Enc(document.getElementById("sms").value);
			txtZip(xhr, "t:amph&tele:" + tele + "&code:" + code + "&smsa:" + sms + "&ivca:" + verifycode, 1);
		}
		if (type == "sendsms") {
			var tele = txtB64Enc(document.getElementById("tele").value);
			var code = txtB64Enc(document.getElementById("code").value);
			txtZip(xhr, "t:nsmm&tele:" + tele + "&code:" + code + "&ivca:" + verifycode);
		}
		if (type == "newimg") {
			var cnt = document.getElementById("ivc").value = ++counter;
			txtZip(xhr, "t:nivc&cnta:" + cnt);
		}
	}

	function cookiemyFunction(arr) {
		switch (arr.result) {
		case "ok":
			myTimer("newimg");
			document.getElementById("totalSpace").textContent = showSpace(arr.totd, arr.usdd);
			break;
		default:
			alert('请先登录后，再操作！');
			window.location.href = "user.htm";
			return false;
		}
	}

	function myFunction(arr) {
		switch (arr.result) {
			case "ok":
				countdown();		// 倒计时
				alert("短信验证码已发送到您的手机上，请正确填写！");
				break;
			case "tele":
				alert("手机号不正确");
				return false;
			case "ivca":
				alert("图片验证码过期");
				return false;
			case "code":
				alert("图片验证码错误");
				return false;
			case "same":
				alert("修改的手机号码与绑定的手机号码一致");
				return false;
			default:
				alert("其它错误");
				return false;
		}
	}

	function confirmFunction(arr) {
		switch (arr.result) {
			case "ok":
				alert("修改手机号成功");
				window.location.href = "center.htm";
				break;
			case "tele":
				alert("手机号不正确");
				return false;
			case "ivca":
				alert("图片验证码过期");
				return false;
			case "code":
				alert("图片验证码错误");
				return false;
			case "smsa":
				alert("短信验证码错误");
				return false;
			case "same":
				alert("修改的手机号码与绑定的手机号码一致");
				return false;
			default:
				alert("其它错误");
				return false;
		}
	}

</script>

</html>